<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>来源：segmentfault</title>
    <script src="../../js/vue.js"></script>
</head>
<body>
<!--https://segmentfault.com/a/1190000007516967-->
    <div id="app">
        <p>
            <button @click="inc">+</button>
            {{count}}
            <button @click="dec">-</button>
        </p>
    </div>
</body>
<script>
    var vm=new Vue({
        el:'#app',
        data:{
            count:0
        },
        methods:{
            inc:function () {
                this.count++;
            },
            dec:function(){
                this.count--;
            }
        }
    })
</script>
</html>